﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsConveter;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;

namespace UnitTestLibrary
{
    [TestClass]
    public class UnitTest1
    {
        [Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer.UITestMethod]
        public void TestIsNullConverter()
        {
            var f = new IsNullConverter();
            Assert.AreEqual(true,f.Convert(null, null, null, null));
            Assert.AreEqual(false, f.Convert(new object(), null, null, null));

            f.IsValue = "foo";
            f.NotValue = 42;

            Assert.AreEqual("foo", f.Convert(null, null, null, null));
            Assert.AreEqual(42, f.Convert(new object(), null, null, null));
        }


        [Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer.UITestMethod]
        public void TestIsNullOrEmptyConverter() {
            var f = new IsNullOrEmptyConverter();
            Assert.AreEqual(true, f.Convert(null, null, null, null));
            Assert.AreEqual(true, f.Convert(Enumerable.Empty<object>(), null, null, null));
            Assert.AreEqual(false, f.Convert(Enumerable.Repeat("s", 1), null, null, null));

            f.IsValue = "foo";
            f.NotValue = 42;

            Assert.AreEqual("foo", f.Convert(null, null, null, null));
            Assert.AreEqual("foo", f.Convert(Enumerable.Empty<object>(), null, null, null));
            Assert.AreEqual(42, f.Convert(Enumerable.Repeat("s", 1), null, null, null));
        }

        [Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer.UITestMethod]
        public void TestIsTrueConverter() {
            var f = new IsTrueConverter();
            Assert.AreEqual(true, f.Convert(false, null, null, null));
            Assert.AreEqual(false, f.Convert(true, null, null, null));

            f.IsValue = "foo";
            f.NotValue = 42;

            Assert.AreEqual(42, f.Convert(false, null, null, null));
            Assert.AreEqual("foo", f.Convert(true, null, null, null));
        }

        [Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer.UITestMethod]
        public void TestIsNullOrWhiteSpaceConverter() {
            var f = new IsNullOrWhiteSpaceConverter();
            Assert.AreEqual(true, f.Convert("", null, null, null));
            Assert.AreEqual(true, f.Convert(" ", null, null, null));
            Assert.AreEqual(false, f.Convert("f", null, null, null));

            f.IsValue = "foo";
            f.NotValue = 42;

            Assert.AreEqual("foo", f.Convert("", null, null, null));
            Assert.AreEqual("foo", f.Convert(" ", null, null, null));
            Assert.AreEqual(42, f.Convert("f", null, null, null));
        }
    }
}
